#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    long long t = 0;
    cin >> t;
    while (t--) {
        int ans = 1;
        int size = 0;
        int k = 0;
        cin >> size;
        cin >> k;
        vector<int> l(size);
        vector<int> r(size);
        for (int i = 0; i < size; i++) {
            cin >> l[i];
        }
        for (int i = 0; i < size; i++) {
            cin >> r[i];
            if (r[i] > l[i]) {//取走r[i]
                ans += r[i];
                r[i] = l[i];//将l[i]更新到r[i]
            }
            else {
                ans += l[i];//保留r,无需操作
            }
        }
        sort(r.begin(), r.end());
        for (int i = size-1; k > 1; k--) {
            ans += r[i];
            i--;
        }          
        cout << ans << endl;
    }
    return 0;
}
